#include "stdafx.h"
#include "CameraTest.h"
#include "TestItemInterface.h"
#include "TestDlg.h"


CTestDlg* g_pDlg = NULL;

// Run test
// Return: Test result, see definition of TEST_RESULT_ENUM
TEST_RESULT_ENUM  TestItemRun()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	g_pDlg = new CTestDlg;
	TEST_RESULT_ENUM testResult = (TEST_RESULT_ENUM)g_pDlg->DoModal();
	delete g_pDlg;
	g_pDlg = NULL;

	return testResult;
}


// Get the title of the test item
// szTitle (out) - Output the test item's title.
void TestItemGetTitle(CString& szTitle)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	if (!szTitle.LoadStringW(IDS_TEST_TITLE))
	{
		szTitle = _T("Unknown");
	}
}


// Process keyboard messages
// The keyboard messages were hooked by the HiMmiTest.exe, 
// the test item's dll can implement this interface to get keyboard messages from exe,
// and if the dll don't care the keyboard message, needn't implement this function.
//
LRESULT  TestItemProcessKbdMsg(int nCode, WPARAM wParam, LPARAM lParam)
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState());

    if(NULL == g_pDlg)
    {
        return S_FALSE;
    }

    if(nCode >= 0)
    {
        if (IsWindowVisible(g_pDlg->m_hWnd))
        {
            ::SendMessage(g_pDlg->m_hWnd, WM_KEYBOARD, wParam, lParam);
        }
    }

    return S_OK;
}

